home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 August: Tool Chest / Dev.CD Aug 00 TC Disk 2.toast / pc / sample code / interapplication comm / folder watching / fw receiver / patchlistldef.c < prev    next >
Encoding:
Text File  |  2000-06-23  |  2.3 KB  |  119 lines

  1. /*
  2.     File:        PatchListLDEF.c
  3.  
  4.     Contains:    
  5.  
  6.     Written by:     
  7.  
  8.     Copyright:    Copyright © 1995-1999 by Apple Computer, Inc., All Rights Reserved.
  9.  
  10.                 You may incorporate this Apple sample source code into your program(s) without
  11.                 restriction. This Apple sample source code has been provided "AS IS" and the
  12.                 responsibility for its operation is yours. You are not permitted to redistribute
  13.                 this Apple sample source code as "Apple sample source code" after having made
  14.                 changes. If you're going to re-distribute the source, we require that you make
  15.                 it clear in the source that the code was descended from Apple sample source
  16.                 code, but that you've made changes.
  17.  
  18.     Change History (most recent first):
  19.                 7/21/1999    Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
  20.                 
  21.  
  22. */
  23. // System includes
  24.  
  25. #ifndef __TYPES__
  26.     #include <Types.h>
  27. #endif
  28.  
  29. #ifndef __LISTS__
  30.     #include <Lists.h>
  31. #endif
  32.  
  33. #ifndef __OSUTILS__
  34.     #include <OSUtils.h>
  35. #endif
  36.  
  37.  
  38. // Application includes
  39.  
  40. #ifndef __BAREBONES__
  41.     #include "BareBones.h"
  42. #endif
  43.  
  44.  
  45. #ifndef USE_LDEF
  46.  
  47.  
  48. pascal void tabsLDEF ( short theMessage, short selFlags, Rect* theRect, Cell theCell,
  49.                                short theOffset, short theLen, ListRef theHandle );
  50.  
  51.  
  52.  
  53.  
  54.  
  55. #if GENERATINGPOWERPC
  56. #pragma options align=mac68k
  57. #endif
  58.  
  59.  
  60. #if GENERATINGCFM
  61. typedef struct
  62. {
  63.     RoutineDescriptor    routineDescriptor;
  64.     
  65. } LDEFPatch, *LDEFPatchPtr, **LDEFPatchHndl;
  66. #else
  67. typedef struct
  68. {
  69.     short    jmpInst;
  70.     ProcPtr    patchAddr;
  71.     
  72. } LDEFPatch, *LDEFPatchPtr, **LDEFPatchHndl;
  73. #endif
  74.  
  75. #if GENERATINGPOWERPC
  76. #pragma options align=reset
  77. #endif
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84. OSErr PatchListLDEF ( ListRef theList );
  85.  
  86.  
  87. OSErr PatchListLDEF ( ListRef theList )
  88. {
  89.     OSErr                theErr;
  90.     LDEFPatchHndl        ldefHndl;
  91.     LDEFPatchPtr        ldefPatch;
  92.     RoutineDescriptor    initializedRD = BUILD_ROUTINE_DESCRIPTOR ( uppListDefProcInfo,
  93.                                                                     tabsLDEF );
  94.     
  95.     ldefHndl = (LDEFPatchHndl) NewHandle ( sizeof ( LDEFPatch ) );
  96.     theErr = MemError ( );
  97.     if ( theErr )
  98.         return theErr;
  99.     
  100.     HLock ( (Handle) ldefHndl );
  101.     ldefPatch = *ldefHndl;
  102.     
  103. #if GENERATINGCFM
  104.     ldefPatch->routineDescriptor = initializedRD;
  105. #else
  106.     ldefPatch->jmpInst = 0x4EF9;                    // a 68K JMP instruction
  107.     ldefPatch->patchAddr = (ProcPtr) tabsLDEF;        // where we want to jmp
  108. #endif
  109.     
  110.     HUnlock ( (Handle) ldefHndl );
  111.     (*theList)->listDefProc = (Handle) ldefHndl;
  112.     
  113.     return noErr;
  114. }
  115.  
  116.  
  117. #endif
  118.  
  119.